ENH: Support concatenate_epochs() for EpochsTFR#13745
ENH: Support concatenate_epochs() for EpochsTFR#13745aman-coder03 wants to merge 6 commits intomne-tools:mainfrom
concatenate_epochs() for EpochsTFR#13745Conversation
mne/epochs.py
Outdated
| shift = np.int64((10 + ref.times[-1]) * ref.info["sfreq"]) | ||
| events_offset = int(np.max(epochs_list[0].events[:, 0])) + shift |
There was a problem hiding this comment.
| shift = np.int64((10 + ref.times[-1]) * ref.info["sfreq"]) | |
| events_offset = int(np.max(epochs_list[0].events[:, 0])) + shift | |
| shift = len(ref.times) | |
| events_offset = ref.events[-1, 0] + shift |
nordme
left a comment
There was a problem hiding this comment.
Hi @aman-coder03 ! Thanks for the PR.
I took a look at the concatenation function and tests, and it's looking pretty good so nice work. I spotted a few more EpochsTFR attributes that need handling.
Attributes to check:
ep.baseline
Even if the times arrays are equivalent across epochs instances, some instances could have baselines where others have none, and that's a problem. For concatenation, baselines should be the same across instances.ep.method
We should check that the method of construction is the same for all our epochs instances (e.g. not mixing multitaper and morlet wavelet TFR results for example).ep.weights
This attribute stores weights for tapers. If applicable, these need to be equivalent across epochs instances.
Attributes that need concatenation:
ep.comment
This attribute typically stores trial descriptions of some sort and might not be the same across epochs instances (e.g. 'run 1', 'run2', 'run 3'). These need to be put together for the returned epochs instance.
Cheers.
|
thanks for the reviews... shift = len(ref.times)
events_offset = ref.events[-1, 0] + shiftaddressed all three attribute checks @nordme
regarding |
|
@aman-coder03 I think you're right we can ignore the comment attribute since the |
Reference issue (if any)
towards #13191
What does this implement/fix?
concatenate_epochs()now works withEpochsTFRobjects. Before this, passing a list ofEpochsTFRinstances would just crash with aTypeErrorbecauseEpochsTFRisn't a subclass ofBaseEpochsfix adds a helper function
_concatenate_epochs_tfr()inmne/epochs.pythat takes care of stacking the data, merging event IDs, offsetting event timestamps, and handling metadata, basically the same things the existing concatenation does for regular epochsconcatenate_epochs()now checks if it's dealing withEpochsTFRobjects and routes to this helper automaticallytests are added in
mne/time_frequency/tests/test_tfr.pyAdditional information
task 1 of 3 from #13191 (as discussed with @drammock)
tasks 2 and 3(
EpochsSpectrumsupport and allowingEpochsTFRto acceptRawTFRas input) will come in follow up PRs